package cn.demoncat.util.pay.yeepay.entity;

import cn.demoncat.util.pay.yeepay.constant.TradeRefundStatus;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 响应参数-退款状态查询
 *
 * @author 延晓磊
 * @since 2020年10月19日
 */
public class TradeRefundQueryResult extends YeepayResult{

    // 订单编号（对应交易订单）
    private String orderId;
    // 易宝收款订单号（对应交易订单）
    private String uniqueOrderNo;
    // 退款申请号
    private String refundRequestId;
    // 易宝退款单号
    private String uniqueRefundNo;
    // 退款金额（元）
    private BigDecimal refundAmount;
    // 退还手续费（元）
    private BigDecimal returnMerchantFee;
    // 退款原因（可空）
    private String description;
    // 退款请求时间
    private LocalDateTime refundRequestDate;
    // 退款成功时间
    private LocalDateTime refundSuccessDate;
    // 退款状态：TradeRefundStatus.name()
    private String status;
    // 退款失败原因
    private String failReason;


    /**
     * 构建结果
     *
     * @param other 请求结果
     * @return
     */
    public static TradeRefundQueryResult build(YeepayResult other){
        return build(other.check(null,null,"OPR00000"), TradeRefundQueryResult.class);
    }

    /**
     * 查询退款状态
     */
    public TradeRefundStatus status() {
        if (this.status != null) {
            return TradeRefundStatus.valueOf(this.status);
        }
        return null;
    }


    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getRefundRequestId() {
        return refundRequestId;
    }

    public void setRefundRequestId(String refundRequestId) {
        this.refundRequestId = refundRequestId;
    }

    public String getUniqueRefundNo() {
        return uniqueRefundNo;
    }

    public void setUniqueRefundNo(String uniqueRefundNo) {
        this.uniqueRefundNo = uniqueRefundNo;
    }

    public BigDecimal getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(BigDecimal refundAmount) {
        this.refundAmount = refundAmount;
    }

    public LocalDateTime getRefundRequestDate() {
        return refundRequestDate;
    }

    public void setRefundRequestDate(LocalDateTime refundRequestDate) {
        this.refundRequestDate = refundRequestDate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getUniqueOrderNo() {
        return uniqueOrderNo;
    }

    public void setUniqueOrderNo(String uniqueOrderNo) {
        this.uniqueOrderNo = uniqueOrderNo;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public LocalDateTime getRefundSuccessDate() {
        return refundSuccessDate;
    }

    public void setRefundSuccessDate(LocalDateTime refundSuccessDate) {
        this.refundSuccessDate = refundSuccessDate;
    }

    public String getFailReason() {
        return failReason;
    }

    public void setFailReason(String failReason) {
        this.failReason = failReason;
    }

    public BigDecimal getReturnMerchantFee() {
        return returnMerchantFee;
    }

    public void setReturnMerchantFee(BigDecimal returnMerchantFee) {
        this.returnMerchantFee = returnMerchantFee;
    }
}
